---
id: mikro
title: automapper/mikro
sidebar_label: automapper/mikro
sidebar_position: 3
---

## Overview

`@automapper/mikro` is an official strategy that works with [MikroORM](https://mikro-orm.io/). `@automapper/mikro` is an extension of `@automapper/classes`

## Installation

```shell
npm i @automapper/core @automapper/classes @automapper/mikro
```

```shell
yarn add @automapper/core @automapper/classes @automapper/mikro
```

## Usage

Using `@automapper/mikro` isn't different from using [`@automapper/classes`](./classes#usage). The difference is `@automapper/mikro` has a custom `preMap` that handles how to serialize the `sourceObject` because of how MikroORM returns the object upon a Retrieve operation.

### `preMap`

The default `preMap` from `@automapper/mikro` checks for Collection, Reference, and Entity recursively to serialize the `sourceObject` to their raw JSON data.

We can customize this `preMap` via `MappingStrategyInitializerOptions`

```ts
const mapper = createMapper({
    strategyInitializer: mikro({ preMap: customPreMap }),
});
```

## Metadata

See [@automapper/classes](./classes#metadata)
